<template>
  <div v-if="!isFooterDuplicate" class="footer dark:bg-gray-900">
    <footer class="bg-white dark:bg-gray-900">
      Copyright © 2025. All rights reserved. Provided by Mindsparkle
    </footer>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';

// 使用一个全局标志来防止重复渲染
const isFooterDuplicate = ref(false);
const footerIdentifier = 'global-footer-rendered';

onMounted(() => {
  // 检查是否已经存在footer
  if (window[footerIdentifier]) {
    isFooterDuplicate.value = true;
  } else {
    window[footerIdentifier] = true;
  }
});

onUnmounted(() => {
  // 当组件卸载时，重置标志
  window[footerIdentifier] = false;
});
</script>

<style scoped>
.footer {
    width: 100%;
    text-align: center;
    padding: 15px 0;
    background-color: #fff;
    color: #666;
    font-size: 14px;
    border-top: 1px solid #f0f0f0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.03);
    margin-top: 30px;
}

/* 添加黑夜模式样式 */
:deep(.dark) .footer, 
:deep(.dark) footer,
.dark .footer,
.dark footer {
    background-color: #111827 !important;
    color: #e5e7eb !important;
    border-top: 1px solid #374151 !important;
    border-color: #374151 !important;
    box-shadow: none !important;
}
</style>